package com.app.couponsharelife.ui.adapter

import androidx.databinding.DataBindingUtil
import android.view.LayoutInflater
import android.view.ViewGroup
import com.app.couponsharelife.R
import com.app.couponsharelife.data.bean.CommonProblemBean
import com.app.couponsharelife.databinding.ProblemListDetailItemBinding

/**
 * Created by guluwa on 2018/11/24.
 */
class ProblemListDetailAdapter(private val list: List<CommonProblemBean.FaqsBean>) :
        androidx.recyclerview.widget.RecyclerView.Adapter<androidx.recyclerview.widget.RecyclerView.ViewHolder>() {

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): androidx.recyclerview.widget.RecyclerView.ViewHolder {
        return ViewHolder(DataBindingUtil.inflate(
                LayoutInflater.from(parent.context), R.layout.problem_list_detail_item, parent, false))
    }

    override fun getItemCount(): Int {
        return list.size
    }

    override fun onBindViewHolder(holder: androidx.recyclerview.widget.RecyclerView.ViewHolder, position: Int) {
        (holder as ViewHolder).databinding.tvProblemTitle.text = list[position].q
        holder.databinding.tvProblemContent.text = list[position].a
    }

    inner class ViewHolder(val databinding: ProblemListDetailItemBinding) : androidx.recyclerview.widget.RecyclerView.ViewHolder(databinding.root)
}